﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace TruyenCuoiViet.ViewModels
{
    public class ItemViewModel : INotifyPropertyChanged
    {
        private int _id;
        public int Id
        {
            get
            {
                return _id;
            }
            set
            {
                if (value != _id)
                {
                    _id = value;
                    NotifyPropertyChanged("Id");
                }
            }
        }
        private string _title;
        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }
        private string _detailUrl;
        public string DetailUrl
        {
            get
            {
                return _detailUrl;
            }
            set
            {
                if (value != _detailUrl)
                {
                    _detailUrl = value;
                    NotifyPropertyChanged("DetailUrl");
                }
            }
        }
        private string _categoryName;
        public string CategoryName
        {
            get
            {
                return _categoryName;
            }
            set
            {
                if (value != _detailUrl)
                {
                    _categoryName = value;
                    NotifyPropertyChanged("CategoryName");
                }
            }
        }
        private string _content;
        public string Content
        {
            get
            {
                return _content;
            }
            set
            {
                if (value != _content)
                {
                    _content = value;
                    NotifyPropertyChanged("Content");
                }
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        public ItemViewModel(int idNews, string title, string detailUrl,string categoryName)
        {
            // TODO: Complete member initialization
            this.Id = idNews;
            this.Title = title;
            this.DetailUrl = detailUrl;
            this.CategoryName = categoryName;
        }
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}